package com.um.info.action;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.cs.framework.common.bo.Message;
import com.cs.framework.ui.web.UI;
import com.cs.framework.web.annotation.Action;
import com.cs.framework.web.annotation.Mapping;
import com.cs.framework.web.handler.Web;
import com.um.info.dto.UmMenuAccessSaveDto;
import com.um.info.service.UmMenuAccessService;

/**
 * UM菜单权限
 *
 * @author hedongzhou
 *
 */
@Action("umMenuAccess")
public class UmMenuAccessAction {

	private Log logger = LogFactory.getLog(getClass());

	@Resource
	private UmMenuAccessService umMenuAccessService;

	/**
	 * 进入菜单权限管理页面
	 */
	@Mapping
	public void mainPage() {
		UI.returnPage("um_mac");
	}

	/**
	 * 保存菜单权限
	 * 
	 * @return
	 */
	@Mapping
	public Object save() {
		UmMenuAccessSaveDto umMenuAccessSaveDto = Web.bind(UmMenuAccessSaveDto.class);

		try {
			umMenuAccessService.save(umMenuAccessSaveDto);

			return new Message("Y", "保存成功");
		} catch (Exception e) {
			logger.error(e.getMessage(), e);

			return new Message("N", e.getMessage());
		}
	}

}
